home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / text / tex / amiweb2c.lha / AmiWeb2c-2.1 / texmf / pastex / rexx / Start_TeX.ced < prev    next >
Encoding:
Text File  |  1997-02-09  |  3.8 KB  |  168 lines

  1. /*
  2. ** AREXX $VER: Start_TeX.ced V1.45 (27.07.1995)
  3. **
  4. ** This AREXX script saves and compiles the current CED Pro 2 view. The only
  5. ** (optional) argument is the format to be used. A '?' formatname will
  6. ** interactively ask for the format to use.
  7. **
  8. ** A command is send to the TeX server to compile the file. Hence a return
  9. ** value of 0 does not mean that the file compiled well, but only that the
  10. ** command was sent to the server and replied to.
  11. **
  12. ** AUTHOR: J\"org H\"ohle, March 91
  13. **
  14. ** BUGS: virtex doesn't like filenames with blanks (and ARexx parses them
  15. **       hardly too), so avoid them in file, directory *and* device names.
  16. **
  17. **       Does not like names relative to the local root, like ":foo/bar".
  18. **
  19. **       CED views may have negative change counts, so test for `equal zero'.
  20. **
  21. ** FILES: ENV:TEXFORMAT     default format used
  22. **        REXX:NameStruc
  23. **
  24. ** CHANGES: 22.04.1994: Quit processing when format selection `cancel'led.
  25. **          23.09.1994: Standard LaTeX2e format is called `latex'.
  26. **          27.07.1995: Start the TeX Server when not already running.
  27. */
  28.  
  29. Options Results
  30.  
  31. PORTNAME = 'Start_TeX'
  32. SCRIPT   = 'TeX-server.rexx' /* no path required, message only */
  33.  
  34. /*
  35. ** 1: Ask interactively for format name
  36. ** 0: Don't
  37. */
  38. If "" = GetClip("TEXQUERY") Then
  39.   ASKFORMAT = 0
  40. Else
  41.   ASKFORMAT = 1
  42.  
  43. Parse Arg FORMAT .
  44. If "?" = FORMAT Then Do
  45.   ASKFORMAT = 1
  46.   FORMAT    = ""
  47. End; Else If '&' = Left(FORMAT,1) Then
  48.   FORMAT = SubStr(FORMAT,2)
  49.  
  50. /*
  51. ** Get the full filename from CED
  52. */
  53. Status 19
  54. FULLNAME = RESULT
  55.  
  56. /*
  57. ** We need an absolute name
  58. */
  59. Parse Value NameStruc(FULLNAME) With IVOL IDIRS IBASE .
  60.  
  61. /*
  62. ** Do we really have a TeX input file?
  63. */
  64. If "" = SubStr(FULLNAME,1+IVOL+IDIRS+IBASE) | Upper(Right(FULLNAME,3)) ~= "TEX" Then Do
  65.  
  66. /*
  67. ** Or is it a LateX input file?  Then change the FORMAT.
  68. */
  69.   If "" = SubStr(FULLNAME,1+IVOL+IDIRS+IBASE) | Upper(Right(FULLNAME,3)) ~= "LTX" Then Do
  70.     Okay1 "Fehler, die Datei muß eine Endung `.tex' oder `.ltx' haben."
  71.     Exit 5
  72.   End; Else Do
  73.     If ASKFORMAT = 1 Then
  74.       FORMAT = ""
  75.     Else
  76.       FORMAT = 'latex'
  77.   End
  78. End
  79.  
  80. If 0 = IVOL Then Do
  81.   DIREC = Pragma('d')
  82.   If Right(DIREC,1) ~= '/' & Right(DIREC,1) ~= ':' Then
  83.     DIREC = DIREC||'/'
  84.   FULLNAME = DIREC||FULLNAME
  85.   Drop DIREC
  86. End
  87. Drop IVOL IDIRS IBASE
  88.  
  89. /*
  90. ** Save only if file has been modified.
  91. ** So get the number of changes to the file.
  92. */
  93. Status 18
  94. If 0 ~= RESULT Then
  95.   Save
  96.  
  97. /*
  98. ** Start the TeX Server before the current job, when it is not
  99. ** already running.  There is a little timing problem to be solved.
  100. */
  101. If ~Show('Port',PORTNAME) Then Do
  102.   Address Command "InitTeX"
  103.   Address Command "WaitForPort Start_TeX"
  104. End
  105.  
  106. If Show('Port',PORTNAME) Then Do
  107. /*
  108. ** Set the default TEXFORMAT, modify it to suit your needs.
  109. */
  110.   ENVFORMAT = MyGetEnv("TEXFORMAT")
  111.   If "" = FORMAT Then Do
  112.     FORMAT = ENVFORMAT
  113.     If ASKFORMAT | "" = ENVFORMAT Then Do
  114.       If "" = FORMAT Then
  115.         FORMAT = 'plain'
  116.       'GetString 'FORMAT '"Welches Format soll benutzt werden?"'
  117.       NFORMAT = RESULT
  118. /*
  119. ** "RESULT" if cancelled
  120. */
  121.       If "RESULT" ~= NFORMAT Then
  122.         FORMAT = NFORMAT
  123.       Else
  124.         Exit
  125.     End /* ASKFORMAT */
  126.   End   /* FORMAT    */
  127.  
  128. /*
  129. ** If the server is already busy with some compilation, this will
  130. ** wait until the compilation finishes, this may take a long time
  131. ** because no unlocking (like in MG) is available
  132. */
  133.   If FORMAT ~= ENVFORMAT Then
  134.     Call MySetEnv("TEXFORMAT",FORMAT)
  135.  
  136.   Address Value PORTNAME
  137.   'compile' FORMAT FULLNAME
  138. End; Else Do
  139. /*
  140. ** The TeX server must be started first
  141. */
  142.   Okay1 'Der TeX-Server läuft nicht!'
  143.   Exit 5
  144. End
  145.  
  146. Exit
  147.  
  148. /*
  149. ** When will Arexx supply GetEnv/SetEnv ?
  150. */
  151. MyGetEnv: Procedure
  152. Parse Arg NAME
  153.  
  154. If Open(TEMPFILE,"ENV:"||NAME,'r') Then Do
  155.   GIVES = Readln(TEMPFILE)
  156.   Call Close TEMPFILE
  157. End; Else
  158.   GIVES = ""
  159.  
  160. Return GIVES
  161.  
  162. MySetEnv: Procedure
  163. Parse Arg NAME,CONTENT
  164.  
  165. Address COMMAND "SetEnv" NAME CONTENT
  166.  
  167. Return
  168.